package com.etc.controller;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.etc.entity.Employee;
import com.etc.entity.Job;
import com.etc.service.JobService;
import com.etc.util.ResponseData;
import com.github.pagehelper.Page;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * 
 * @ClassName: JobController
 * @Description: @RestController = @Controller + @ResponseBody
 * @author knowno
 * @date 2022年4月7日 上午9:51:24
 *
 */
@RestController
@Api(value = "职位管理控制器", description = "职位管理接口")
public class JobController {
	
	Logger  logger = LogManager.getLogger(JobController.class);

	// 注入一个service
	@Autowired
	private JobService service;

	/**
	 * 
	 * @param page     页码
	 * @param limit    每页记录数
	 * @param keywords 查询关键字
	 * @return
	 */
	@GetMapping(value = "job")
	@ApiOperation(value = "职位的模糊查询", httpMethod = "GET", notes = "模糊查询方法", response = ResponseData.class)
	public ResponseData<Job> getJob(@RequestParam(value = "page", required = true, defaultValue = "1") Integer page,
			@RequestParam(value = "limit", required = true, defaultValue = "10") Integer limit,
			@RequestParam(value = "keywords", required = true, defaultValue = "") @ApiParam(value = "关键字", name = "keywords", required = false) String keywords) {
		Page<Job> pages = service.getByPage(page, limit, keywords);

		ResponseData<Job> rdata = new ResponseData<Job>(pages.getTotal(), pages.getResult());

		return rdata;
	}

}
